﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace XC153_ISP_Maintenanc
{
    /// <summary>
    /// ExportConfirmDialog.xaml 的交互逻辑
    /// </summary>
    public partial class ExportConfirmDialog : Window
    {
        public bool ExportConfirmed { get; private set; } = false;
        public ExportConfirmDialog()
        {
            InitializeComponent();
            LoadFirmwareVersion();
            StartVersionBlinking();
        }
        private void LoadFirmwareVersion()
        {
            try
            {
                string firmwareVersion = System.Configuration.ConfigurationManager.AppSettings["FirmwareVersion"];

                if (!string.IsNullOrEmpty(firmwareVersion))
                {
                    FirmwareVersionText.Text = firmwareVersion;
                }
                else
                {
                    FirmwareVersionText.Text = "未知版本";
                }
            }
            catch (Exception ex)
            {
                FirmwareVersionText.Text = "配置错误";
                // 可以记录日志，这里不显示消息框避免干扰用户体验
                System.Diagnostics.Debug.WriteLine($"读取固件版本配置失败: {ex.Message}");
            }
        }

        private void StartVersionBlinking()
        {
            var storyboard = (System.Windows.Media.Animation.Storyboard)this.Resources["VersionBlinkingAnimation"];
            storyboard.Begin(FirmwareVersionText, true);
        }

        private void ConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            ExportConfirmed = true;
            this.DialogResult = true;
            this.Close();
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            ExportConfirmed = false;
            this.DialogResult = false;
            this.Close();
        }
    }
}
